00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00034
00035 require_once (PATH_TO_ROOT."messaging/classes/class.messaging_view.inc.php");
00036
00037 class MessagingOut extends MessagingView {
00038
00044 private $sortby;
00045
00051 private $sortbyRecipient;
00052
00058 private $order;
00059
00065 private $filter;
00066
00067
00072 public function __construct($messaging) {
00073
00074 parent::__construct($messaging);
00075 }
00076
00081 protected function initView() {
00082
00083 $this->sortbyRecipient = false;
00084 if (isset ( $_GET ["sortby"] )) {
00085 switch ($_GET ["sortby"]) {
00086 case "empfaenger" :
00087 $this->sortbyRecipient = true;
00088 break;
00089
00090 case "betreff" :
00091 $this->sortby = "messaging_outbox.subject";
00092 break;
00093
00094 case "datum" :
00095 $this->sortby = "messaging_outbox.date";
00096 break;
00097
00098 default :
00099 $this->sortby = "messaging_outbox.date";
00100 break;
00101 }
00102 } else {
00103 $this->sortby = "messaging_outbox.date";
00104 }
00105
00106
00107 if (isset($_GET["order"]) && $_GET["order"] == "auf") {
00108 $this->order = "ASC";
00109 }
00110 else {
00111 $this->order = "DESC";
00112 }
00113
00114
00115 if(isset($_POST ["filterText"])) {
00116 $this->filter = Data::toMysql(Data::toHTML($_POST["filterText"]));
00117 }
00118 else {
00119 $this->filter = NULL;
00120 }
00121
00122 return true;
00123 }
00124
00129 protected function checkActions() {
00130 if (isset($_GET["action"]) && $_GET["action"] == "delete") {
00131 $deleteReturn = $this->messaging->deleteMessage($_GET["messageID"], "outbox");
00132 if (! $deleteReturn) {
00133 Output::echoMessage ( $this->translate->_ ( "Fehler beim Loeschen der Nachricht!" ), 0, true );
00134 } else {
00135 Output::echoMessage ( $this->translate->_ ( "Nachricht erfolgreich geloescht!" ), 0, true );
00136 }
00137 }
00138 if (isset ( $_POST ["deleteButton"] )) {
00139 $messages = array ();
00140 if (isset ( $_POST ["selectedMessages"] ))
00141 $messages = $_POST ["selectedMessages"];
00142 $count = count ( $messages );
00143 for($i = 0; $i < $count; $i ++) {
00144 $deleteReturn = $this->messaging->deleteMessage ( $messages [$i], "inbox" );
00145 if (! $deleteReturn) {
00146 Output::echoMessage ( $this->translate->_ ( "Fehler beim Loeschen der Nachricht!" ), 0, true );
00147 break;
00148 }
00149 Output::echoMessage ( $this->translate->_ ( "Nachricht erfolgreich geloescht!" ), 0, true );
00150 }
00151 } elseif (isset($_POST["archiveButton"])) {
00152 $messages = array();
00153 if (isset ( $_POST ["selectedMessages"] ))
00154 $messages = $_POST["selectedMessages"];
00155 $count = count($messages);
00156 for ($i = 0 ; $i < $count ; $i++) {
00157 $this->messaging->archiveMessage($messages[$i], "outbox");
00158 }
00159 }
00160 return true;
00161 }
00162
00168 function echoOutbox() {
00169 if($this->execution) {
00170 global $settings;
00171
00172 echo "<form id='messageAction' method='post' action='".PATH_TO_ROOT.SCRIPT_NAME."'>
00173 <table class='tableBorder' width='100%'>";
00174 Output::echoTableHead ($this->translate->_("Gesendete Nachrichten") , 4 );
00175
00176 echo "<tr><td colspan='4'>".($settings ["pm_days_to_delete_messages"] > 0 ? "<span class='text10'>".
00177 sprintf($this->translate->_("Hinweis: Nicht archivierte Nachrichten werden nach %1\$s Tagen geloescht."),$settings["pm_days_to_delete_messages"]).
00178 "</span>" : "");
00179
00180 echo "</td></tr>";
00181
00182 if(isset($this->filter))
00183 {
00184 $messages = $this->db->get_results("SELECT messaging_outbox.*
00185 FROM messaging_outbox
00186 WHERE messaging_outbox.userID =".$this->messaging->getUserID()." AND messaging_outbox.subject LIKE '%".$this->filter."%'");
00187 $num = $this->db->num_rows;
00188
00189 $firstRecipient = array();
00190 if ($num != 0) {
00191 foreach($messages as $message) {
00192 $recipientIDs = explode(";", $message->recipientID);
00193 $value = $recipientIDs[0].":::".$message->ID;
00194 array_push($firstRecipient, $value);
00195
00196 }
00197
00198 $recipientIDname = array();
00199 $count = count($firstRecipient);
00200 for ($i = 0 ; $i < $count ; $i++) {
00201 $recipientID = explode(":::", $firstRecipient[$i]);
00202 $name = $this->db->get_row("SELECT nachname, vorname
00203 FROM user
00204 WHERE user.ID =".$recipientID[0]);
00205 $value = $name->nachname.",".$name->vorname.":::".$recipientID[1];
00206 array_push($recipientIDname, $value);
00207 }
00208 }
00209
00210 }
00211 else {
00212
00213 if (!$this->sortbyRecipient) {
00214 $messages = $this->db->get_results("SELECT messaging_outbox.*
00215 FROM messaging_outbox
00216 WHERE messaging_outbox.userID =".$this->messaging->getUserID()." ORDER BY ".$this->sortby." ".$this->order);
00217 $num = $this->db->num_rows;
00218 }
00219 else {
00220 $messages = $this->db->get_results("SELECT messaging_outbox.*
00221 FROM messaging_outbox
00222 WHERE messaging_outbox.userID =".$this->messaging->getUserID());
00223 $num = $this->db->num_rows;
00224
00225 $firstRecipient = array();
00226 foreach($messages as $message) {
00227 $recipientIDs = explode(";", $message->recipientID);
00228 $value = $recipientIDs[0].":::".$message->ID;
00229 array_push($firstRecipient, $value);
00230
00231 }
00232
00233 $recipientIDname = array();
00234 $count = count($firstRecipient);
00235 for ($i = 0 ; $i < $count ; $i++) {
00236 $recipientID = explode(":::", $firstRecipient[$i]);
00237 $name = $this->db->get_row("SELECT nachname, vorname
00238 FROM user
00239 WHERE user.ID =".$recipientID[0]);
00240 $value = $name->nachname.",".$name->vorname.":::".$recipientID[1];
00241 array_push($recipientIDname, $value);
00242 }
00243 if ($_GET["order"] == "auf") sort($recipientIDname, SORT_STRING);
00244 else rsort($recipientIDname, SORT_STRING);
00245
00246 }
00247 }
00248
00249 if ($num > 0) {
00250 if(isset($this->filter) && $this->filter != "")
00251
00252 {
00253 Output::echoMessage("Filter: ".$this->filter,4);
00254
00255 echo "<tr>
00256 <td class='tableCellHead'>".$this->translate->_("Absender")."</td>
00257 <td class='tableCellHead'>".$this->translate->_("Betreff")."</td>
00258 <td class='tableCellHead'>".$this->translate->_("Datum")."</td>
00259 <td class='tableCellHead'><a href='".PATH_TO_ROOT."pdf/build.php?type=pdf&target=pn&id=recv'>".Output::getIcon("icon_pdf", $this->translate->_("Alle empfangenen Nachrichten als PDF exportieren")) ."</a>
00260 </td>
00261 </tr>";
00262 }
00263 else
00264 {
00265 echo "<tr>
00266 <td class='tableCellHead'><a href='".PATH_TO_ROOT.SCRIPT_NAME."?sortby=von&order=".$this->messaging->getOrderByLink("von") ."'>".$this->translate->_("Absender")."</a></td>
00267 <td class='tableCellHead'><a href='".PATH_TO_ROOT.SCRIPT_NAME."?sortby=betreff&order=".$this->messaging->getOrderByLink("betreff") ."'>".$this->translate->_("Betreff")."</a></td>
00268 <td class='tableCellHead'><a href='".PATH_TO_ROOT.SCRIPT_NAME."?sortby=datum&order=".$this->messaging->getOrderByLink("datum") ."'>".$this->translate->_("Datum")."</a></td>
00269 <td class='tableCellHead'><a href='".PATH_TO_ROOT."pdf/build.php?type=pdf&target=pn&id=recv'>".Output::getIcon("icon_pdf", $this->translate->_("Alle empfangenen Nachrichten als PDF exportieren")) ."</a>
00270 </td>
00271 </tr>";
00272 }
00273 $darkCell = true;
00274 if (!$this->sortbyRecipient) {
00275 foreach($messages as $message) {
00276 $image = "";
00277 if ($message->isArchived == 1) $image = Output::getIcon("icon_emailarchiv", $this->translate->_("Nachricht im Archiv"));
00278 $recipIDs = trim(str_replace(";", ",", $message->recipientID));
00279
00280 if (substr($recipIDs, -1, 1)==",") $recipIDs = substr($recipIDs, 0, -1);
00281 $sql = "SELECT isRead FROM messaging_inbox WHERE userID IN (".$recipIDs.") AND authorID='".$this->messaging->getUserID().
00282 "' AND subject='".Data::toMysql($message->subject, false) ."' AND message='".Data::toMysql($message->message, false).
00283 "' AND date BETWEEN ".($message->date-1) ." AND ".($message->date+1);
00284 if (substr_count($message->recipientID, ";") > 1) {
00285 $isRead = $this->db->get_col($sql);
00286 if (!is_array($isRead)) {
00287 $isRead = true;
00288 } else {
00289 $isRead = !in_array("0", $isRead);
00290 }
00291 $altText = $this->translate->_("Mindestens ein Empfaenger hat die Nachricht noch nicht gelesen");
00292 } else {
00293 $isRead = (bool)$this->db->get_var($sql);
00294 $altText = $this->translate->_("Empfaenger hat die Nachricht noch nicht gelesen");
00295 }
00296 if (!$this->db->num_rows) $isRead = true;
00297 if (!$isRead) $image.= Output::getIcon("icon_mail", $altText);
00298
00299
00300 $date = new Zend_Date($message->date, Zend_Date::TIMESTAMP);
00301 $date = $date->get(Zend_Date::DATE_SHORT)." - ".$date->get(Zend_Date::TIME_SHORT);
00302 $message->date = $date;
00303
00304 $strEmpfaenger = $this->messaging->getRecipients($message->recipientID, 2, 1);
00305 $darkCell == true ? $class = "tableCellDark" : $class = "tableCell";
00306
00307
00308 echo " <tr valign='top'>
00309 <td class='".$class."'>".$strEmpfaenger."</td>
00310 <td class='".$class."'><a href='".PATH_TO_ROOT."messaging/".PATH_TO_MESSAGE_DETAIL."?type=outbox&messageID=".$message->ID."'>".$image.$message->subject."</a></td>
00311 <td class='".$class."'>".$message->date."</td>
00312 <td class='".$class."' align='center'><p class='pForm'><input type='checkbox' name='selectedMessages[]' value='".$message->ID."' ";
00313 if (isset($_POST["markAll"])) echo "checked='checked' ";
00314 echo "/></p></td></tr>";
00315 $darkCell == true ? $darkCell = false : $darkCell = true;
00316 }
00317 } else {
00318 $count = count($recipientIDname);
00319 for ($i = 0 ; $i < $count ; $i++) {
00320 $messageID = explode(":::", $recipientIDname[$i]);
00321 $message = $this->db->get_row("SELECT *
00322 FROM messaging_outbox
00323 WHERE messaging_outbox.ID =".$messageID[1]);
00324
00325 $image = "";
00326 if ($message->isArchived == 1) $image = Output::getIcon("icon_emailarchiv", $this->translate->_("Nachricht im Archiv"));
00327
00328
00329 $date = new Zend_Date($message->date, Zend_Date::TIMESTAMP);
00330 $date = $date->get(Zend_Date::DATE_SHORT)." - ".$date->get(Zend_Date::TIME_SHORT);
00331 $message->date = $date;
00332
00333 $strEmpfaenger = $this->messaging->getRecipients($message->recipientID, 2, 1);
00334 $darkCell == true ? $class = "tableCellDark" : $class = "tableCell";
00335 echo " <td class='".$class."'>".$strEmpfaenger."</td>
00336 <td class='".$class."'><a href='".PATH_TO_ROOT."messaging/".PATH_TO_MESSAGE_DETAIL."?type=outbox&messageID=".$message->ID."'>".$image." ".$message->subject."</a></td>
00337 <td class='".$class."'>".$message->date."</td>
00338 <td class='".$class."' align='center' valign='middle'><p class='pForm'><input type='checkbox' name='selectedMessages[]' value='".$message->ID."' ";
00339 if (isset($_POST["markAll"])) echo "checked='checked' ";
00340 echo "/></p></td></tr>";
00341 $darkCell == true ? $darkCell = false : $darkCell = true;
00342 }
00343 }
00344
00345 $filterzeile = "<p class='pForm'>".$this->translate->_("Betreffzeile filtern nach").": <input type='text' name='filterText' value='" . $this->filter . "'/> <input type='submit' name='filterButton' value='".$this->translate->_("Filter anwenden")."'/></p> ";
00346
00347 if (isset($this->filter))
00348
00349 {
00350 Output::echoDialogBottom(array("okButton" => "","resetButton" => "","cancelButton" => ""), 4, true, $filterzeile);
00351 }
00352 else
00353
00354 {
00355 Output::echoDialogBottom(array("okButton" => "","resetButton" => "","cancelButton" => ""), 4, true, $filterzeile);
00356 }
00357
00358
00359 $bottomButtons = "</p> <p class='pForm'><input type='submit' name='deleteButton' value='".$this->translate->_("Loeschen")."'/></p> <p class='pForm'><input type='submit' name='archiveButton' value='".$this->translate->_("Archivieren")."'/></p> ";
00360
00361 if (isset($_POST["markAll"]))
00362 {
00363 $bottomButtons = "<p class='pForm'><input type='submit' name='markNone' value='".$this->translate->_("Nichts markieren")."'/>".$bottomButtons;
00364 Output::echoDialogBottom(array("okButton" => "","cancelButton" => ""), 4, true, $bottomButtons);
00365 }
00366 else
00367 {
00368 $bottomButtons = "<p class='pForm'><input type='submit' name='markAll' value='".$this->translate->_("Alles markieren")."'/>".$bottomButtons;
00369 Output::echoDialogBottom(array("okButton" => "","cancelButton" => ""), 4, true, $bottomButtons);
00370 }
00371 }
00372
00373 else if (($this->db->num_rows == 0)and(isset($this->filter))and($this->filter!=""))
00374 {
00375
00376 Output::errorMessage($this->translate->_("Filter").": ".$this->filter,4);
00377 echo "<tr><td>".$this->translate->_("Keine Nachrichten die dem Filter entsprechen")."</td></tr>";
00378
00379
00380 $filterzeile = "<p class='pForm'>".$this->translate->_("Betreffzeile filtern nach").": <input type='text' name='filterText' value='" . $this->filter . "'/> <input type='submit' name='filterButton' value='".$this->translate->_("Filter anwenden")."'/></p> ";
00381 Output::echoDialogBottom(array("okButton" => "","resetButton" => "","cancelButton" => ""), 4, true, $filterzeile);
00382
00383
00384 }
00385
00386 else {
00387 echo "<tr><td>".$this->translate->_("Keine neuen Nachrichten").".</td></tr>";
00388 }
00389 echo "</table></form>";
00390 }
00391 }
00392 }
00393 ?>